

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import App from './App.vue'
import locale from 'element-plus/dist/locale/zh-cn.js'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { getUserStore } from './stores/user'

const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
app.use(router)
app.use(ElementPlus,{locale})
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 应用挂载后初始化用户识别
app.mount('#app')

// 初始化用户识别系统
const initializeUserSystem = async () => {
  console.log('🚀 启动华南师范大学VR展馆预约系统')
  console.log('📱 正在初始化用户识别系统...')
  
  try {
    const userStore = getUserStore()
    await userStore.initializeUser()
    
    console.log('✅ 用户识别系统初始化完成')
    
    // 在控制台显示用户信息摘要
    const summary = userStore.getUserSummary()
    console.log('👤 用户信息摘要:', summary)
    
  } catch (error) {
    console.error('❌ 用户识别系统初始化失败:', error)
  }
}

// 页面加载完成后初始化
window.addEventListener('load', initializeUserSystem)
